// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.
#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]

/// Implements a client for the Discovery Engine API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_discoveryengine_v1::client::AssistantService;
/// let client = AssistantService::builder().build().await?;
/// // use `client` to make requests to the Discovery Engine API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Service for managing Assistant configuration and assisting users.
///
/// # Configuration
///
/// To configure `AssistantService` use the `with_*` methods in the type returned
/// by [builder()][AssistantService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://discoveryengine.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::assistant_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::assistant_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `AssistantService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `AssistantService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[cfg(feature = "assistant-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "assistant-service")))]
#[derive(Clone, Debug)]
pub struct AssistantService {
    inner: std::sync::Arc<dyn super::stub::dynamic::AssistantService>,
}

#[cfg(feature = "assistant-service")]
impl AssistantService {
    /// Returns a builder for [AssistantService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::client::AssistantService;
    /// let client = AssistantService::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::assistant_service::ClientBuilder {
        gax::client_builder::internal::new_builder(
            super::builder::assistant_service::client::Factory,
        )
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::AssistantService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::AssistantService>>
    {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::AssistantService> {
        super::transport::AssistantService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::AssistantService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::AssistantService::new)
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::assistant_service::ListOperations {
        super::builder::assistant_service::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::assistant_service::GetOperation {
        super::builder::assistant_service::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn cancel_operation(&self) -> super::builder::assistant_service::CancelOperation {
        super::builder::assistant_service::CancelOperation::new(self.inner.clone())
    }
}

/// Implements a client for the Discovery Engine API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_discoveryengine_v1::client::CmekConfigService;
/// let client = CmekConfigService::builder().build().await?;
/// // use `client` to make requests to the Discovery Engine API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Service for managing CMEK related tasks
///
/// # Configuration
///
/// To configure `CmekConfigService` use the `with_*` methods in the type returned
/// by [builder()][CmekConfigService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://discoveryengine.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::cmek_config_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::cmek_config_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `CmekConfigService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `CmekConfigService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[cfg(feature = "cmek-config-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "cmek-config-service")))]
#[derive(Clone, Debug)]
pub struct CmekConfigService {
    inner: std::sync::Arc<dyn super::stub::dynamic::CmekConfigService>,
}

#[cfg(feature = "cmek-config-service")]
impl CmekConfigService {
    /// Returns a builder for [CmekConfigService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::client::CmekConfigService;
    /// let client = CmekConfigService::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::cmek_config_service::ClientBuilder {
        gax::client_builder::internal::new_builder(
            super::builder::cmek_config_service::client::Factory,
        )
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::CmekConfigService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::CmekConfigService>>
    {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::CmekConfigService> {
        super::transport::CmekConfigService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::CmekConfigService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::CmekConfigService::new)
    }

    /// Provisions a CMEK key for use in a location of a customer's project.
    /// This method will also conduct location validation on the provided
    /// cmekConfig to make sure the key is valid and can be used in the
    /// selected location.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn update_cmek_config(&self) -> super::builder::cmek_config_service::UpdateCmekConfig {
        super::builder::cmek_config_service::UpdateCmekConfig::new(self.inner.clone())
    }

    /// Gets the [CmekConfig][google.cloud.discoveryengine.v1.CmekConfig].
    ///
    /// [google.cloud.discoveryengine.v1.CmekConfig]: crate::model::CmekConfig
    pub fn get_cmek_config(&self) -> super::builder::cmek_config_service::GetCmekConfig {
        super::builder::cmek_config_service::GetCmekConfig::new(self.inner.clone())
    }

    /// Lists all the [CmekConfig][google.cloud.discoveryengine.v1.CmekConfig]s
    /// with the project.
    ///
    /// [google.cloud.discoveryengine.v1.CmekConfig]: crate::model::CmekConfig
    pub fn list_cmek_configs(&self) -> super::builder::cmek_config_service::ListCmekConfigs {
        super::builder::cmek_config_service::ListCmekConfigs::new(self.inner.clone())
    }

    /// De-provisions a CmekConfig.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_cmek_config(&self) -> super::builder::cmek_config_service::DeleteCmekConfig {
        super::builder::cmek_config_service::DeleteCmekConfig::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::cmek_config_service::ListOperations {
        super::builder::cmek_config_service::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::cmek_config_service::GetOperation {
        super::builder::cmek_config_service::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn cancel_operation(&self) -> super::builder::cmek_config_service::CancelOperation {
        super::builder::cmek_config_service::CancelOperation::new(self.inner.clone())
    }
}

/// Implements a client for the Discovery Engine API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_discoveryengine_v1::client::CompletionService;
/// let client = CompletionService::builder().build().await?;
/// // use `client` to make requests to the Discovery Engine API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Service for Auto-Completion.
///
/// # Configuration
///
/// To configure `CompletionService` use the `with_*` methods in the type returned
/// by [builder()][CompletionService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://discoveryengine.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::completion_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::completion_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `CompletionService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `CompletionService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[cfg(feature = "completion-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "completion-service")))]
#[derive(Clone, Debug)]
pub struct CompletionService {
    inner: std::sync::Arc<dyn super::stub::dynamic::CompletionService>,
}

#[cfg(feature = "completion-service")]
impl CompletionService {
    /// Returns a builder for [CompletionService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::client::CompletionService;
    /// let client = CompletionService::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::completion_service::ClientBuilder {
        gax::client_builder::internal::new_builder(
            super::builder::completion_service::client::Factory,
        )
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::CompletionService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::CompletionService>>
    {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::CompletionService> {
        super::transport::CompletionService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::CompletionService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::CompletionService::new)
    }

    /// Completes the specified user input with keyword suggestions.
    pub fn complete_query(&self) -> super::builder::completion_service::CompleteQuery {
        super::builder::completion_service::CompleteQuery::new(self.inner.clone())
    }

    /// Imports all
    /// [SuggestionDenyListEntry][google.cloud.discoveryengine.v1.SuggestionDenyListEntry]
    /// for a DataStore.
    ///
    /// [google.cloud.discoveryengine.v1.SuggestionDenyListEntry]: crate::model::SuggestionDenyListEntry
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn import_suggestion_deny_list_entries(
        &self,
    ) -> super::builder::completion_service::ImportSuggestionDenyListEntries {
        super::builder::completion_service::ImportSuggestionDenyListEntries::new(self.inner.clone())
    }

    /// Permanently deletes all
    /// [SuggestionDenyListEntry][google.cloud.discoveryengine.v1.SuggestionDenyListEntry]
    /// for a DataStore.
    ///
    /// [google.cloud.discoveryengine.v1.SuggestionDenyListEntry]: crate::model::SuggestionDenyListEntry
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn purge_suggestion_deny_list_entries(
        &self,
    ) -> super::builder::completion_service::PurgeSuggestionDenyListEntries {
        super::builder::completion_service::PurgeSuggestionDenyListEntries::new(self.inner.clone())
    }

    /// Imports
    /// [CompletionSuggestion][google.cloud.discoveryengine.v1.CompletionSuggestion]s
    /// for a DataStore.
    ///
    /// [google.cloud.discoveryengine.v1.CompletionSuggestion]: crate::model::CompletionSuggestion
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn import_completion_suggestions(
        &self,
    ) -> super::builder::completion_service::ImportCompletionSuggestions {
        super::builder::completion_service::ImportCompletionSuggestions::new(self.inner.clone())
    }

    /// Permanently deletes all
    /// [CompletionSuggestion][google.cloud.discoveryengine.v1.CompletionSuggestion]s
    /// for a DataStore.
    ///
    /// [google.cloud.discoveryengine.v1.CompletionSuggestion]: crate::model::CompletionSuggestion
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn purge_completion_suggestions(
        &self,
    ) -> super::builder::completion_service::PurgeCompletionSuggestions {
        super::builder::completion_service::PurgeCompletionSuggestions::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::completion_service::ListOperations {
        super::builder::completion_service::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::completion_service::GetOperation {
        super::builder::completion_service::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn cancel_operation(&self) -> super::builder::completion_service::CancelOperation {
        super::builder::completion_service::CancelOperation::new(self.inner.clone())
    }
}

/// Implements a client for the Discovery Engine API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_discoveryengine_v1::client::ControlService;
/// let client = ControlService::builder().build().await?;
/// // use `client` to make requests to the Discovery Engine API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Service for performing CRUD operations on Controls.
/// Controls allow for custom logic to be implemented in the serving path.
/// Controls need to be attached to a Serving Config to be considered during a
/// request.
///
/// # Configuration
///
/// To configure `ControlService` use the `with_*` methods in the type returned
/// by [builder()][ControlService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://discoveryengine.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::control_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::control_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `ControlService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `ControlService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[cfg(feature = "control-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "control-service")))]
#[derive(Clone, Debug)]
pub struct ControlService {
    inner: std::sync::Arc<dyn super::stub::dynamic::ControlService>,
}

#[cfg(feature = "control-service")]
impl ControlService {
    /// Returns a builder for [ControlService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::client::ControlService;
    /// let client = ControlService::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::control_service::ClientBuilder {
        gax::client_builder::internal::new_builder(super::builder::control_service::client::Factory)
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::ControlService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::ControlService>> {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::ControlService> {
        super::transport::ControlService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::ControlService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::ControlService::new)
    }

    /// Creates a Control.
    ///
    /// By default 1000 controls are allowed for a data store.
    /// A request can be submitted to adjust this limit.
    /// If the [Control][google.cloud.discoveryengine.v1.Control] to create already
    /// exists, an ALREADY_EXISTS error is returned.
    ///
    /// [google.cloud.discoveryengine.v1.Control]: crate::model::Control
    pub fn create_control(&self) -> super::builder::control_service::CreateControl {
        super::builder::control_service::CreateControl::new(self.inner.clone())
    }

    /// Deletes a Control.
    ///
    /// If the [Control][google.cloud.discoveryengine.v1.Control] to delete does
    /// not exist, a NOT_FOUND error is returned.
    ///
    /// [google.cloud.discoveryengine.v1.Control]: crate::model::Control
    pub fn delete_control(&self) -> super::builder::control_service::DeleteControl {
        super::builder::control_service::DeleteControl::new(self.inner.clone())
    }

    /// Updates a Control.
    ///
    /// [Control][google.cloud.discoveryengine.v1.Control] action type cannot be
    /// changed. If the [Control][google.cloud.discoveryengine.v1.Control] to
    /// update does not exist, a NOT_FOUND error is returned.
    ///
    /// [google.cloud.discoveryengine.v1.Control]: crate::model::Control
    pub fn update_control(&self) -> super::builder::control_service::UpdateControl {
        super::builder::control_service::UpdateControl::new(self.inner.clone())
    }

    /// Gets a Control.
    pub fn get_control(&self) -> super::builder::control_service::GetControl {
        super::builder::control_service::GetControl::new(self.inner.clone())
    }

    /// Lists all Controls by their parent
    /// [DataStore][google.cloud.discoveryengine.v1.DataStore].
    ///
    /// [google.cloud.discoveryengine.v1.DataStore]: crate::model::DataStore
    pub fn list_controls(&self) -> super::builder::control_service::ListControls {
        super::builder::control_service::ListControls::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::control_service::ListOperations {
        super::builder::control_service::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::control_service::GetOperation {
        super::builder::control_service::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn cancel_operation(&self) -> super::builder::control_service::CancelOperation {
        super::builder::control_service::CancelOperation::new(self.inner.clone())
    }
}

/// Implements a client for the Discovery Engine API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_discoveryengine_v1::client::ConversationalSearchService;
/// let client = ConversationalSearchService::builder().build().await?;
/// // use `client` to make requests to the Discovery Engine API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Service for conversational search.
///
/// # Configuration
///
/// To configure `ConversationalSearchService` use the `with_*` methods in the type returned
/// by [builder()][ConversationalSearchService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://discoveryengine.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::conversational_search_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::conversational_search_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `ConversationalSearchService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `ConversationalSearchService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[cfg(feature = "conversational-search-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "conversational-search-service")))]
#[derive(Clone, Debug)]
pub struct ConversationalSearchService {
    inner: std::sync::Arc<dyn super::stub::dynamic::ConversationalSearchService>,
}

#[cfg(feature = "conversational-search-service")]
impl ConversationalSearchService {
    /// Returns a builder for [ConversationalSearchService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::client::ConversationalSearchService;
    /// let client = ConversationalSearchService::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::conversational_search_service::ClientBuilder {
        gax::client_builder::internal::new_builder(
            super::builder::conversational_search_service::client::Factory,
        )
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::ConversationalSearchService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<
        std::sync::Arc<dyn super::stub::dynamic::ConversationalSearchService>,
    > {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::ConversationalSearchService> {
        super::transport::ConversationalSearchService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::ConversationalSearchService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::ConversationalSearchService::new)
    }

    /// Converses a conversation.
    pub fn converse_conversation(
        &self,
    ) -> super::builder::conversational_search_service::ConverseConversation {
        super::builder::conversational_search_service::ConverseConversation::new(self.inner.clone())
    }

    /// Creates a Conversation.
    ///
    /// If the [Conversation][google.cloud.discoveryengine.v1.Conversation] to
    /// create already exists, an ALREADY_EXISTS error is returned.
    ///
    /// [google.cloud.discoveryengine.v1.Conversation]: crate::model::Conversation
    pub fn create_conversation(
        &self,
    ) -> super::builder::conversational_search_service::CreateConversation {
        super::builder::conversational_search_service::CreateConversation::new(self.inner.clone())
    }

    /// Deletes a Conversation.
    ///
    /// If the [Conversation][google.cloud.discoveryengine.v1.Conversation] to
    /// delete does not exist, a NOT_FOUND error is returned.
    ///
    /// [google.cloud.discoveryengine.v1.Conversation]: crate::model::Conversation
    pub fn delete_conversation(
        &self,
    ) -> super::builder::conversational_search_service::DeleteConversation {
        super::builder::conversational_search_service::DeleteConversation::new(self.inner.clone())
    }

    /// Updates a Conversation.
    ///
    /// [Conversation][google.cloud.discoveryengine.v1.Conversation] action type
    /// cannot be changed. If the
    /// [Conversation][google.cloud.discoveryengine.v1.Conversation] to update does
    /// not exist, a NOT_FOUND error is returned.
    ///
    /// [google.cloud.discoveryengine.v1.Conversation]: crate::model::Conversation
    pub fn update_conversation(
        &self,
    ) -> super::builder::conversational_search_service::UpdateConversation {
        super::builder::conversational_search_service::UpdateConversation::new(self.inner.clone())
    }

    /// Gets a Conversation.
    pub fn get_conversation(
        &self,
    ) -> super::builder::conversational_search_service::GetConversation {
        super::builder::conversational_search_service::GetConversation::new(self.inner.clone())
    }

    /// Lists all Conversations by their parent
    /// [DataStore][google.cloud.discoveryengine.v1.DataStore].
    ///
    /// [google.cloud.discoveryengine.v1.DataStore]: crate::model::DataStore
    pub fn list_conversations(
        &self,
    ) -> super::builder::conversational_search_service::ListConversations {
        super::builder::conversational_search_service::ListConversations::new(self.inner.clone())
    }

    /// Answer query method.
    pub fn answer_query(&self) -> super::builder::conversational_search_service::AnswerQuery {
        super::builder::conversational_search_service::AnswerQuery::new(self.inner.clone())
    }

    /// Gets a Answer.
    pub fn get_answer(&self) -> super::builder::conversational_search_service::GetAnswer {
        super::builder::conversational_search_service::GetAnswer::new(self.inner.clone())
    }

    /// Creates a Session.
    ///
    /// If the [Session][google.cloud.discoveryengine.v1.Session] to create already
    /// exists, an ALREADY_EXISTS error is returned.
    ///
    /// [google.cloud.discoveryengine.v1.Session]: crate::model::Session
    pub fn create_session(&self) -> super::builder::conversational_search_service::CreateSession {
        super::builder::conversational_search_service::CreateSession::new(self.inner.clone())
    }

    /// Deletes a Session.
    ///
    /// If the [Session][google.cloud.discoveryengine.v1.Session] to delete does
    /// not exist, a NOT_FOUND error is returned.
    ///
    /// [google.cloud.discoveryengine.v1.Session]: crate::model::Session
    pub fn delete_session(&self) -> super::builder::conversational_search_service::DeleteSession {
        super::builder::conversational_search_service::DeleteSession::new(self.inner.clone())
    }

    /// Updates a Session.
    ///
    /// [Session][google.cloud.discoveryengine.v1.Session] action type cannot be
    /// changed. If the [Session][google.cloud.discoveryengine.v1.Session] to
    /// update does not exist, a NOT_FOUND error is returned.
    ///
    /// [google.cloud.discoveryengine.v1.Session]: crate::model::Session
    pub fn update_session(&self) -> super::builder::conversational_search_service::UpdateSession {
        super::builder::conversational_search_service::UpdateSession::new(self.inner.clone())
    }

    /// Gets a Session.
    pub fn get_session(&self) -> super::builder::conversational_search_service::GetSession {
        super::builder::conversational_search_service::GetSession::new(self.inner.clone())
    }

    /// Lists all Sessions by their parent
    /// [DataStore][google.cloud.discoveryengine.v1.DataStore].
    ///
    /// [google.cloud.discoveryengine.v1.DataStore]: crate::model::DataStore
    pub fn list_sessions(&self) -> super::builder::conversational_search_service::ListSessions {
        super::builder::conversational_search_service::ListSessions::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::conversational_search_service::ListOperations {
        super::builder::conversational_search_service::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::conversational_search_service::GetOperation {
        super::builder::conversational_search_service::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn cancel_operation(
        &self,
    ) -> super::builder::conversational_search_service::CancelOperation {
        super::builder::conversational_search_service::CancelOperation::new(self.inner.clone())
    }
}

/// Implements a client for the Discovery Engine API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_discoveryengine_v1::client::DataStoreService;
/// let client = DataStoreService::builder().build().await?;
/// // use `client` to make requests to the Discovery Engine API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Service for managing [DataStore][google.cloud.discoveryengine.v1.DataStore]
/// configuration.
///
/// [google.cloud.discoveryengine.v1.DataStore]: crate::model::DataStore
///
/// # Configuration
///
/// To configure `DataStoreService` use the `with_*` methods in the type returned
/// by [builder()][DataStoreService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://discoveryengine.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::data_store_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::data_store_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `DataStoreService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `DataStoreService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[cfg(feature = "data-store-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "data-store-service")))]
#[derive(Clone, Debug)]
pub struct DataStoreService {
    inner: std::sync::Arc<dyn super::stub::dynamic::DataStoreService>,
}

#[cfg(feature = "data-store-service")]
impl DataStoreService {
    /// Returns a builder for [DataStoreService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::client::DataStoreService;
    /// let client = DataStoreService::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::data_store_service::ClientBuilder {
        gax::client_builder::internal::new_builder(
            super::builder::data_store_service::client::Factory,
        )
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::DataStoreService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::DataStoreService>>
    {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::DataStoreService> {
        super::transport::DataStoreService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::DataStoreService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::DataStoreService::new)
    }

    /// Creates a [DataStore][google.cloud.discoveryengine.v1.DataStore].
    ///
    /// DataStore is for storing
    /// [Documents][google.cloud.discoveryengine.v1.Document]. To serve these
    /// documents for Search, or Recommendation use case, an
    /// [Engine][google.cloud.discoveryengine.v1.Engine] needs to be created
    /// separately.
    ///
    /// [google.cloud.discoveryengine.v1.DataStore]: crate::model::DataStore
    /// [google.cloud.discoveryengine.v1.Document]: crate::model::Document
    /// [google.cloud.discoveryengine.v1.Engine]: crate::model::Engine
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_data_store(&self) -> super::builder::data_store_service::CreateDataStore {
        super::builder::data_store_service::CreateDataStore::new(self.inner.clone())
    }

    /// Gets a [DataStore][google.cloud.discoveryengine.v1.DataStore].
    ///
    /// [google.cloud.discoveryengine.v1.DataStore]: crate::model::DataStore
    pub fn get_data_store(&self) -> super::builder::data_store_service::GetDataStore {
        super::builder::data_store_service::GetDataStore::new(self.inner.clone())
    }

    /// Lists all the [DataStore][google.cloud.discoveryengine.v1.DataStore]s
    /// associated with the project.
    ///
    /// [google.cloud.discoveryengine.v1.DataStore]: crate::model::DataStore
    pub fn list_data_stores(&self) -> super::builder::data_store_service::ListDataStores {
        super::builder::data_store_service::ListDataStores::new(self.inner.clone())
    }

    /// Deletes a [DataStore][google.cloud.discoveryengine.v1.DataStore].
    ///
    /// [google.cloud.discoveryengine.v1.DataStore]: crate::model::DataStore
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_data_store(&self) -> super::builder::data_store_service::DeleteDataStore {
        super::builder::data_store_service::DeleteDataStore::new(self.inner.clone())
    }

    /// Updates a [DataStore][google.cloud.discoveryengine.v1.DataStore]
    ///
    /// [google.cloud.discoveryengine.v1.DataStore]: crate::model::DataStore
    pub fn update_data_store(&self) -> super::builder::data_store_service::UpdateDataStore {
        super::builder::data_store_service::UpdateDataStore::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::data_store_service::ListOperations {
        super::builder::data_store_service::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::data_store_service::GetOperation {
        super::builder::data_store_service::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn cancel_operation(&self) -> super::builder::data_store_service::CancelOperation {
        super::builder::data_store_service::CancelOperation::new(self.inner.clone())
    }
}

/// Implements a client for the Discovery Engine API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_discoveryengine_v1::client::DocumentService;
/// let client = DocumentService::builder().build().await?;
/// // use `client` to make requests to the Discovery Engine API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Service for ingesting [Document][google.cloud.discoveryengine.v1.Document]
/// information of the customer's website.
///
/// [google.cloud.discoveryengine.v1.Document]: crate::model::Document
///
/// # Configuration
///
/// To configure `DocumentService` use the `with_*` methods in the type returned
/// by [builder()][DocumentService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://discoveryengine.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::document_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::document_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `DocumentService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `DocumentService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[cfg(feature = "document-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "document-service")))]
#[derive(Clone, Debug)]
pub struct DocumentService {
    inner: std::sync::Arc<dyn super::stub::dynamic::DocumentService>,
}

#[cfg(feature = "document-service")]
impl DocumentService {
    /// Returns a builder for [DocumentService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::client::DocumentService;
    /// let client = DocumentService::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::document_service::ClientBuilder {
        gax::client_builder::internal::new_builder(
            super::builder::document_service::client::Factory,
        )
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::DocumentService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::DocumentService>>
    {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::DocumentService> {
        super::transport::DocumentService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::DocumentService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::DocumentService::new)
    }

    /// Gets a [Document][google.cloud.discoveryengine.v1.Document].
    ///
    /// [google.cloud.discoveryengine.v1.Document]: crate::model::Document
    pub fn get_document(&self) -> super::builder::document_service::GetDocument {
        super::builder::document_service::GetDocument::new(self.inner.clone())
    }

    /// Gets a list of [Document][google.cloud.discoveryengine.v1.Document]s.
    ///
    /// [google.cloud.discoveryengine.v1.Document]: crate::model::Document
    pub fn list_documents(&self) -> super::builder::document_service::ListDocuments {
        super::builder::document_service::ListDocuments::new(self.inner.clone())
    }

    /// Creates a [Document][google.cloud.discoveryengine.v1.Document].
    ///
    /// [google.cloud.discoveryengine.v1.Document]: crate::model::Document
    pub fn create_document(&self) -> super::builder::document_service::CreateDocument {
        super::builder::document_service::CreateDocument::new(self.inner.clone())
    }

    /// Updates a [Document][google.cloud.discoveryengine.v1.Document].
    ///
    /// [google.cloud.discoveryengine.v1.Document]: crate::model::Document
    pub fn update_document(&self) -> super::builder::document_service::UpdateDocument {
        super::builder::document_service::UpdateDocument::new(self.inner.clone())
    }

    /// Deletes a [Document][google.cloud.discoveryengine.v1.Document].
    ///
    /// [google.cloud.discoveryengine.v1.Document]: crate::model::Document
    pub fn delete_document(&self) -> super::builder::document_service::DeleteDocument {
        super::builder::document_service::DeleteDocument::new(self.inner.clone())
    }

    /// Bulk import of multiple
    /// [Document][google.cloud.discoveryengine.v1.Document]s. Request processing
    /// may be synchronous. Non-existing items are created.
    ///
    /// Note: It is possible for a subset of the
    /// [Document][google.cloud.discoveryengine.v1.Document]s to be successfully
    /// updated.
    ///
    /// [google.cloud.discoveryengine.v1.Document]: crate::model::Document
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn import_documents(&self) -> super::builder::document_service::ImportDocuments {
        super::builder::document_service::ImportDocuments::new(self.inner.clone())
    }

    /// Permanently deletes all selected
    /// [Document][google.cloud.discoveryengine.v1.Document]s in a branch.
    ///
    /// This process is asynchronous. Depending on the number of
    /// [Document][google.cloud.discoveryengine.v1.Document]s to be deleted, this
    /// operation can take hours to complete. Before the delete operation
    /// completes, some [Document][google.cloud.discoveryengine.v1.Document]s might
    /// still be returned by
    /// [DocumentService.GetDocument][google.cloud.discoveryengine.v1.DocumentService.GetDocument]
    /// or
    /// [DocumentService.ListDocuments][google.cloud.discoveryengine.v1.DocumentService.ListDocuments].
    ///
    /// To get a list of the [Document][google.cloud.discoveryengine.v1.Document]s
    /// to be deleted, set
    /// [PurgeDocumentsRequest.force][google.cloud.discoveryengine.v1.PurgeDocumentsRequest.force]
    /// to false.
    ///
    /// [google.cloud.discoveryengine.v1.Document]: crate::model::Document
    /// [google.cloud.discoveryengine.v1.DocumentService.GetDocument]: crate::client::DocumentService::get_document
    /// [google.cloud.discoveryengine.v1.DocumentService.ListDocuments]: crate::client::DocumentService::list_documents
    /// [google.cloud.discoveryengine.v1.PurgeDocumentsRequest.force]: crate::model::PurgeDocumentsRequest::force
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn purge_documents(&self) -> super::builder::document_service::PurgeDocuments {
        super::builder::document_service::PurgeDocuments::new(self.inner.clone())
    }

    /// Gets index freshness metadata for
    /// [Document][google.cloud.discoveryengine.v1.Document]s. Supported for
    /// website search only.
    ///
    /// [google.cloud.discoveryengine.v1.Document]: crate::model::Document
    pub fn batch_get_documents_metadata(
        &self,
    ) -> super::builder::document_service::BatchGetDocumentsMetadata {
        super::builder::document_service::BatchGetDocumentsMetadata::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::document_service::ListOperations {
        super::builder::document_service::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::document_service::GetOperation {
        super::builder::document_service::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn cancel_operation(&self) -> super::builder::document_service::CancelOperation {
        super::builder::document_service::CancelOperation::new(self.inner.clone())
    }
}

/// Implements a client for the Discovery Engine API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_discoveryengine_v1::client::EngineService;
/// let client = EngineService::builder().build().await?;
/// // use `client` to make requests to the Discovery Engine API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Service for managing [Engine][google.cloud.discoveryengine.v1.Engine]
/// configuration.
///
/// [google.cloud.discoveryengine.v1.Engine]: crate::model::Engine
///
/// # Configuration
///
/// To configure `EngineService` use the `with_*` methods in the type returned
/// by [builder()][EngineService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://discoveryengine.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::engine_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::engine_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `EngineService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `EngineService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[cfg(feature = "engine-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "engine-service")))]
#[derive(Clone, Debug)]
pub struct EngineService {
    inner: std::sync::Arc<dyn super::stub::dynamic::EngineService>,
}

#[cfg(feature = "engine-service")]
impl EngineService {
    /// Returns a builder for [EngineService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::client::EngineService;
    /// let client = EngineService::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::engine_service::ClientBuilder {
        gax::client_builder::internal::new_builder(super::builder::engine_service::client::Factory)
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::EngineService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::EngineService>> {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::EngineService> {
        super::transport::EngineService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::EngineService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::EngineService::new)
    }

    /// Creates a [Engine][google.cloud.discoveryengine.v1.Engine].
    ///
    /// [google.cloud.discoveryengine.v1.Engine]: crate::model::Engine
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_engine(&self) -> super::builder::engine_service::CreateEngine {
        super::builder::engine_service::CreateEngine::new(self.inner.clone())
    }

    /// Deletes a [Engine][google.cloud.discoveryengine.v1.Engine].
    ///
    /// [google.cloud.discoveryengine.v1.Engine]: crate::model::Engine
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_engine(&self) -> super::builder::engine_service::DeleteEngine {
        super::builder::engine_service::DeleteEngine::new(self.inner.clone())
    }

    /// Updates an [Engine][google.cloud.discoveryengine.v1.Engine]
    ///
    /// [google.cloud.discoveryengine.v1.Engine]: crate::model::Engine
    pub fn update_engine(&self) -> super::builder::engine_service::UpdateEngine {
        super::builder::engine_service::UpdateEngine::new(self.inner.clone())
    }

    /// Gets a [Engine][google.cloud.discoveryengine.v1.Engine].
    ///
    /// [google.cloud.discoveryengine.v1.Engine]: crate::model::Engine
    pub fn get_engine(&self) -> super::builder::engine_service::GetEngine {
        super::builder::engine_service::GetEngine::new(self.inner.clone())
    }

    /// Lists all the [Engine][google.cloud.discoveryengine.v1.Engine]s associated
    /// with the project.
    ///
    /// [google.cloud.discoveryengine.v1.Engine]: crate::model::Engine
    pub fn list_engines(&self) -> super::builder::engine_service::ListEngines {
        super::builder::engine_service::ListEngines::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::engine_service::ListOperations {
        super::builder::engine_service::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::engine_service::GetOperation {
        super::builder::engine_service::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn cancel_operation(&self) -> super::builder::engine_service::CancelOperation {
        super::builder::engine_service::CancelOperation::new(self.inner.clone())
    }
}

/// Implements a client for the Discovery Engine API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_discoveryengine_v1::client::GroundedGenerationService;
/// let client = GroundedGenerationService::builder().build().await?;
/// // use `client` to make requests to the Discovery Engine API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Service for grounded generation.
///
/// # Configuration
///
/// To configure `GroundedGenerationService` use the `with_*` methods in the type returned
/// by [builder()][GroundedGenerationService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://discoveryengine.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::grounded_generation_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::grounded_generation_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `GroundedGenerationService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `GroundedGenerationService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[cfg(feature = "grounded-generation-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "grounded-generation-service")))]
#[derive(Clone, Debug)]
pub struct GroundedGenerationService {
    inner: std::sync::Arc<dyn super::stub::dynamic::GroundedGenerationService>,
}

#[cfg(feature = "grounded-generation-service")]
impl GroundedGenerationService {
    /// Returns a builder for [GroundedGenerationService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::client::GroundedGenerationService;
    /// let client = GroundedGenerationService::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::grounded_generation_service::ClientBuilder {
        gax::client_builder::internal::new_builder(
            super::builder::grounded_generation_service::client::Factory,
        )
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::GroundedGenerationService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<
        std::sync::Arc<dyn super::stub::dynamic::GroundedGenerationService>,
    > {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::GroundedGenerationService> {
        super::transport::GroundedGenerationService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::GroundedGenerationService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::GroundedGenerationService::new)
    }

    /// Generates grounded content.
    pub fn generate_grounded_content(
        &self,
    ) -> super::builder::grounded_generation_service::GenerateGroundedContent {
        super::builder::grounded_generation_service::GenerateGroundedContent::new(
            self.inner.clone(),
        )
    }

    /// Performs a grounding check.
    pub fn check_grounding(&self) -> super::builder::grounded_generation_service::CheckGrounding {
        super::builder::grounded_generation_service::CheckGrounding::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::grounded_generation_service::ListOperations {
        super::builder::grounded_generation_service::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::grounded_generation_service::GetOperation {
        super::builder::grounded_generation_service::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn cancel_operation(&self) -> super::builder::grounded_generation_service::CancelOperation {
        super::builder::grounded_generation_service::CancelOperation::new(self.inner.clone())
    }
}

/// Implements a client for the Discovery Engine API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_discoveryengine_v1::client::IdentityMappingStoreService;
/// let client = IdentityMappingStoreService::builder().build().await?;
/// // use `client` to make requests to the Discovery Engine API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Service for managing Identity Mapping Stores.
///
/// # Configuration
///
/// To configure `IdentityMappingStoreService` use the `with_*` methods in the type returned
/// by [builder()][IdentityMappingStoreService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://discoveryengine.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::identity_mapping_store_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::identity_mapping_store_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `IdentityMappingStoreService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `IdentityMappingStoreService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[cfg(feature = "identity-mapping-store-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "identity-mapping-store-service")))]
#[derive(Clone, Debug)]
pub struct IdentityMappingStoreService {
    inner: std::sync::Arc<dyn super::stub::dynamic::IdentityMappingStoreService>,
}

#[cfg(feature = "identity-mapping-store-service")]
impl IdentityMappingStoreService {
    /// Returns a builder for [IdentityMappingStoreService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::client::IdentityMappingStoreService;
    /// let client = IdentityMappingStoreService::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::identity_mapping_store_service::ClientBuilder {
        gax::client_builder::internal::new_builder(
            super::builder::identity_mapping_store_service::client::Factory,
        )
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::IdentityMappingStoreService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<
        std::sync::Arc<dyn super::stub::dynamic::IdentityMappingStoreService>,
    > {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::IdentityMappingStoreService> {
        super::transport::IdentityMappingStoreService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::IdentityMappingStoreService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::IdentityMappingStoreService::new)
    }

    /// Creates a new Identity Mapping Store.
    pub fn create_identity_mapping_store(
        &self,
    ) -> super::builder::identity_mapping_store_service::CreateIdentityMappingStore {
        super::builder::identity_mapping_store_service::CreateIdentityMappingStore::new(
            self.inner.clone(),
        )
    }

    /// Gets the Identity Mapping Store.
    pub fn get_identity_mapping_store(
        &self,
    ) -> super::builder::identity_mapping_store_service::GetIdentityMappingStore {
        super::builder::identity_mapping_store_service::GetIdentityMappingStore::new(
            self.inner.clone(),
        )
    }

    /// Deletes the Identity Mapping Store.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_identity_mapping_store(
        &self,
    ) -> super::builder::identity_mapping_store_service::DeleteIdentityMappingStore {
        super::builder::identity_mapping_store_service::DeleteIdentityMappingStore::new(
            self.inner.clone(),
        )
    }

    /// Imports a list of Identity Mapping Entries to an Identity Mapping Store.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn import_identity_mappings(
        &self,
    ) -> super::builder::identity_mapping_store_service::ImportIdentityMappings {
        super::builder::identity_mapping_store_service::ImportIdentityMappings::new(
            self.inner.clone(),
        )
    }

    /// Purges specified or all Identity Mapping Entries from an Identity Mapping
    /// Store.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn purge_identity_mappings(
        &self,
    ) -> super::builder::identity_mapping_store_service::PurgeIdentityMappings {
        super::builder::identity_mapping_store_service::PurgeIdentityMappings::new(
            self.inner.clone(),
        )
    }

    /// Lists Identity Mappings in an Identity Mapping Store.
    pub fn list_identity_mappings(
        &self,
    ) -> super::builder::identity_mapping_store_service::ListIdentityMappings {
        super::builder::identity_mapping_store_service::ListIdentityMappings::new(
            self.inner.clone(),
        )
    }

    /// Lists all Identity Mapping Stores.
    pub fn list_identity_mapping_stores(
        &self,
    ) -> super::builder::identity_mapping_store_service::ListIdentityMappingStores {
        super::builder::identity_mapping_store_service::ListIdentityMappingStores::new(
            self.inner.clone(),
        )
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(
        &self,
    ) -> super::builder::identity_mapping_store_service::ListOperations {
        super::builder::identity_mapping_store_service::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::identity_mapping_store_service::GetOperation {
        super::builder::identity_mapping_store_service::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn cancel_operation(
        &self,
    ) -> super::builder::identity_mapping_store_service::CancelOperation {
        super::builder::identity_mapping_store_service::CancelOperation::new(self.inner.clone())
    }
}

/// Implements a client for the Discovery Engine API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_discoveryengine_v1::client::ProjectService;
/// let client = ProjectService::builder().build().await?;
/// // use `client` to make requests to the Discovery Engine API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Service for operations on the
/// [Project][google.cloud.discoveryengine.v1.Project].
///
/// [google.cloud.discoveryengine.v1.Project]: crate::model::Project
///
/// # Configuration
///
/// To configure `ProjectService` use the `with_*` methods in the type returned
/// by [builder()][ProjectService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://discoveryengine.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::project_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::project_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `ProjectService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `ProjectService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[cfg(feature = "project-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "project-service")))]
#[derive(Clone, Debug)]
pub struct ProjectService {
    inner: std::sync::Arc<dyn super::stub::dynamic::ProjectService>,
}

#[cfg(feature = "project-service")]
impl ProjectService {
    /// Returns a builder for [ProjectService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::client::ProjectService;
    /// let client = ProjectService::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::project_service::ClientBuilder {
        gax::client_builder::internal::new_builder(super::builder::project_service::client::Factory)
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::ProjectService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::ProjectService>> {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::ProjectService> {
        super::transport::ProjectService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::ProjectService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::ProjectService::new)
    }

    /// Provisions the project resource. During the
    /// process, related systems will get prepared and initialized.
    ///
    /// Caller must read the [Terms for data
    /// use](https://cloud.google.com/retail/data-use-terms), and optionally
    /// specify in request to provide consent to that service terms.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn provision_project(&self) -> super::builder::project_service::ProvisionProject {
        super::builder::project_service::ProvisionProject::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::project_service::ListOperations {
        super::builder::project_service::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::project_service::GetOperation {
        super::builder::project_service::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn cancel_operation(&self) -> super::builder::project_service::CancelOperation {
        super::builder::project_service::CancelOperation::new(self.inner.clone())
    }
}

/// Implements a client for the Discovery Engine API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_discoveryengine_v1::client::RankService;
/// let client = RankService::builder().build().await?;
/// // use `client` to make requests to the Discovery Engine API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Service for ranking text records.
///
/// # Configuration
///
/// To configure `RankService` use the `with_*` methods in the type returned
/// by [builder()][RankService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://discoveryengine.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::rank_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::rank_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `RankService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `RankService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[cfg(feature = "rank-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "rank-service")))]
#[derive(Clone, Debug)]
pub struct RankService {
    inner: std::sync::Arc<dyn super::stub::dynamic::RankService>,
}

#[cfg(feature = "rank-service")]
impl RankService {
    /// Returns a builder for [RankService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::client::RankService;
    /// let client = RankService::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::rank_service::ClientBuilder {
        gax::client_builder::internal::new_builder(super::builder::rank_service::client::Factory)
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::RankService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::RankService>> {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::RankService> {
        super::transport::RankService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::RankService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::RankService::new)
    }

    /// Ranks a list of text records based on the given input query.
    pub fn rank(&self) -> super::builder::rank_service::Rank {
        super::builder::rank_service::Rank::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::rank_service::ListOperations {
        super::builder::rank_service::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::rank_service::GetOperation {
        super::builder::rank_service::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn cancel_operation(&self) -> super::builder::rank_service::CancelOperation {
        super::builder::rank_service::CancelOperation::new(self.inner.clone())
    }
}

/// Implements a client for the Discovery Engine API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_discoveryengine_v1::client::RecommendationService;
/// let client = RecommendationService::builder().build().await?;
/// // use `client` to make requests to the Discovery Engine API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Service for making recommendations.
///
/// # Configuration
///
/// To configure `RecommendationService` use the `with_*` methods in the type returned
/// by [builder()][RecommendationService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://discoveryengine.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::recommendation_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::recommendation_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `RecommendationService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `RecommendationService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[cfg(feature = "recommendation-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "recommendation-service")))]
#[derive(Clone, Debug)]
pub struct RecommendationService {
    inner: std::sync::Arc<dyn super::stub::dynamic::RecommendationService>,
}

#[cfg(feature = "recommendation-service")]
impl RecommendationService {
    /// Returns a builder for [RecommendationService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::client::RecommendationService;
    /// let client = RecommendationService::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::recommendation_service::ClientBuilder {
        gax::client_builder::internal::new_builder(
            super::builder::recommendation_service::client::Factory,
        )
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::RecommendationService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::RecommendationService>>
    {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::RecommendationService> {
        super::transport::RecommendationService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::RecommendationService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::RecommendationService::new)
    }

    /// Makes a recommendation, which requires a contextual user event.
    pub fn recommend(&self) -> super::builder::recommendation_service::Recommend {
        super::builder::recommendation_service::Recommend::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::recommendation_service::ListOperations {
        super::builder::recommendation_service::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::recommendation_service::GetOperation {
        super::builder::recommendation_service::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn cancel_operation(&self) -> super::builder::recommendation_service::CancelOperation {
        super::builder::recommendation_service::CancelOperation::new(self.inner.clone())
    }
}

/// Implements a client for the Discovery Engine API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_discoveryengine_v1::client::SchemaService;
/// let client = SchemaService::builder().build().await?;
/// // use `client` to make requests to the Discovery Engine API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Service for managing [Schema][google.cloud.discoveryengine.v1.Schema]s.
///
/// [google.cloud.discoveryengine.v1.Schema]: crate::model::Schema
///
/// # Configuration
///
/// To configure `SchemaService` use the `with_*` methods in the type returned
/// by [builder()][SchemaService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://discoveryengine.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::schema_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::schema_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `SchemaService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `SchemaService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[cfg(feature = "schema-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "schema-service")))]
#[derive(Clone, Debug)]
pub struct SchemaService {
    inner: std::sync::Arc<dyn super::stub::dynamic::SchemaService>,
}

#[cfg(feature = "schema-service")]
impl SchemaService {
    /// Returns a builder for [SchemaService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::client::SchemaService;
    /// let client = SchemaService::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::schema_service::ClientBuilder {
        gax::client_builder::internal::new_builder(super::builder::schema_service::client::Factory)
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::SchemaService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::SchemaService>> {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::SchemaService> {
        super::transport::SchemaService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::SchemaService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::SchemaService::new)
    }

    /// Gets a [Schema][google.cloud.discoveryengine.v1.Schema].
    ///
    /// [google.cloud.discoveryengine.v1.Schema]: crate::model::Schema
    pub fn get_schema(&self) -> super::builder::schema_service::GetSchema {
        super::builder::schema_service::GetSchema::new(self.inner.clone())
    }

    /// Gets a list of [Schema][google.cloud.discoveryengine.v1.Schema]s.
    ///
    /// [google.cloud.discoveryengine.v1.Schema]: crate::model::Schema
    pub fn list_schemas(&self) -> super::builder::schema_service::ListSchemas {
        super::builder::schema_service::ListSchemas::new(self.inner.clone())
    }

    /// Creates a [Schema][google.cloud.discoveryengine.v1.Schema].
    ///
    /// [google.cloud.discoveryengine.v1.Schema]: crate::model::Schema
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_schema(&self) -> super::builder::schema_service::CreateSchema {
        super::builder::schema_service::CreateSchema::new(self.inner.clone())
    }

    /// Updates a [Schema][google.cloud.discoveryengine.v1.Schema].
    ///
    /// [google.cloud.discoveryengine.v1.Schema]: crate::model::Schema
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn update_schema(&self) -> super::builder::schema_service::UpdateSchema {
        super::builder::schema_service::UpdateSchema::new(self.inner.clone())
    }

    /// Deletes a [Schema][google.cloud.discoveryengine.v1.Schema].
    ///
    /// [google.cloud.discoveryengine.v1.Schema]: crate::model::Schema
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_schema(&self) -> super::builder::schema_service::DeleteSchema {
        super::builder::schema_service::DeleteSchema::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::schema_service::ListOperations {
        super::builder::schema_service::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::schema_service::GetOperation {
        super::builder::schema_service::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn cancel_operation(&self) -> super::builder::schema_service::CancelOperation {
        super::builder::schema_service::CancelOperation::new(self.inner.clone())
    }
}

/// Implements a client for the Discovery Engine API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_discoveryengine_v1::client::SearchService;
/// let client = SearchService::builder().build().await?;
/// // use `client` to make requests to the Discovery Engine API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Service for search.
///
/// # Configuration
///
/// To configure `SearchService` use the `with_*` methods in the type returned
/// by [builder()][SearchService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://discoveryengine.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::search_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::search_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `SearchService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `SearchService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[cfg(feature = "search-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "search-service")))]
#[derive(Clone, Debug)]
pub struct SearchService {
    inner: std::sync::Arc<dyn super::stub::dynamic::SearchService>,
}

#[cfg(feature = "search-service")]
impl SearchService {
    /// Returns a builder for [SearchService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::client::SearchService;
    /// let client = SearchService::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::search_service::ClientBuilder {
        gax::client_builder::internal::new_builder(super::builder::search_service::client::Factory)
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::SearchService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::SearchService>> {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::SearchService> {
        super::transport::SearchService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::SearchService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::SearchService::new)
    }

    /// Performs a search.
    pub fn search(&self) -> super::builder::search_service::Search {
        super::builder::search_service::Search::new(self.inner.clone())
    }

    /// Performs a search. Similar to the
    /// [SearchService.Search][google.cloud.discoveryengine.v1.SearchService.Search]
    /// method, but a lite version that allows API key for authentication, where
    /// OAuth and IAM checks are not required.
    ///
    /// Only public website search is supported by this method. If data stores and
    /// engines not associated with public website search are specified, a
    /// `FAILED_PRECONDITION` error is returned.
    ///
    /// This method can be used for easy onboarding without having to implement an
    /// authentication backend. However, it is strongly recommended to use
    /// [SearchService.Search][google.cloud.discoveryengine.v1.SearchService.Search]
    /// instead with required OAuth and IAM checks to provide better data security.
    ///
    /// [google.cloud.discoveryengine.v1.SearchService.Search]: crate::client::SearchService::search
    pub fn search_lite(&self) -> super::builder::search_service::SearchLite {
        super::builder::search_service::SearchLite::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::search_service::ListOperations {
        super::builder::search_service::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::search_service::GetOperation {
        super::builder::search_service::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn cancel_operation(&self) -> super::builder::search_service::CancelOperation {
        super::builder::search_service::CancelOperation::new(self.inner.clone())
    }
}

/// Implements a client for the Discovery Engine API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_discoveryengine_v1::client::SearchTuningService;
/// let client = SearchTuningService::builder().build().await?;
/// // use `client` to make requests to the Discovery Engine API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Service for search tuning.
///
/// # Configuration
///
/// To configure `SearchTuningService` use the `with_*` methods in the type returned
/// by [builder()][SearchTuningService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://discoveryengine.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::search_tuning_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::search_tuning_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `SearchTuningService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `SearchTuningService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[cfg(feature = "search-tuning-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "search-tuning-service")))]
#[derive(Clone, Debug)]
pub struct SearchTuningService {
    inner: std::sync::Arc<dyn super::stub::dynamic::SearchTuningService>,
}

#[cfg(feature = "search-tuning-service")]
impl SearchTuningService {
    /// Returns a builder for [SearchTuningService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::client::SearchTuningService;
    /// let client = SearchTuningService::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::search_tuning_service::ClientBuilder {
        gax::client_builder::internal::new_builder(
            super::builder::search_tuning_service::client::Factory,
        )
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::SearchTuningService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::SearchTuningService>>
    {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::SearchTuningService> {
        super::transport::SearchTuningService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::SearchTuningService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::SearchTuningService::new)
    }

    /// Trains a custom model.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn train_custom_model(&self) -> super::builder::search_tuning_service::TrainCustomModel {
        super::builder::search_tuning_service::TrainCustomModel::new(self.inner.clone())
    }

    /// Gets a list of all the custom models.
    pub fn list_custom_models(&self) -> super::builder::search_tuning_service::ListCustomModels {
        super::builder::search_tuning_service::ListCustomModels::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::search_tuning_service::ListOperations {
        super::builder::search_tuning_service::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::search_tuning_service::GetOperation {
        super::builder::search_tuning_service::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn cancel_operation(&self) -> super::builder::search_tuning_service::CancelOperation {
        super::builder::search_tuning_service::CancelOperation::new(self.inner.clone())
    }
}

/// Implements a client for the Discovery Engine API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_discoveryengine_v1::client::ServingConfigService;
/// let client = ServingConfigService::builder().build().await?;
/// // use `client` to make requests to the Discovery Engine API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Service for operations related to
/// [ServingConfig][google.cloud.discoveryengine.v1.ServingConfig].
///
/// [google.cloud.discoveryengine.v1.ServingConfig]: crate::model::ServingConfig
///
/// # Configuration
///
/// To configure `ServingConfigService` use the `with_*` methods in the type returned
/// by [builder()][ServingConfigService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://discoveryengine.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::serving_config_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::serving_config_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `ServingConfigService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `ServingConfigService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[cfg(feature = "serving-config-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "serving-config-service")))]
#[derive(Clone, Debug)]
pub struct ServingConfigService {
    inner: std::sync::Arc<dyn super::stub::dynamic::ServingConfigService>,
}

#[cfg(feature = "serving-config-service")]
impl ServingConfigService {
    /// Returns a builder for [ServingConfigService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::client::ServingConfigService;
    /// let client = ServingConfigService::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::serving_config_service::ClientBuilder {
        gax::client_builder::internal::new_builder(
            super::builder::serving_config_service::client::Factory,
        )
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::ServingConfigService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::ServingConfigService>>
    {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::ServingConfigService> {
        super::transport::ServingConfigService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::ServingConfigService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::ServingConfigService::new)
    }

    /// Updates a ServingConfig.
    ///
    /// Returns a NOT_FOUND error if the ServingConfig does not exist.
    pub fn update_serving_config(
        &self,
    ) -> super::builder::serving_config_service::UpdateServingConfig {
        super::builder::serving_config_service::UpdateServingConfig::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::serving_config_service::ListOperations {
        super::builder::serving_config_service::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::serving_config_service::GetOperation {
        super::builder::serving_config_service::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn cancel_operation(&self) -> super::builder::serving_config_service::CancelOperation {
        super::builder::serving_config_service::CancelOperation::new(self.inner.clone())
    }
}

/// Implements a client for the Discovery Engine API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_discoveryengine_v1::client::SessionService;
/// let client = SessionService::builder().build().await?;
/// // use `client` to make requests to the Discovery Engine API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Service for managing Sessions and Session-related resources.
///
/// # Configuration
///
/// To configure `SessionService` use the `with_*` methods in the type returned
/// by [builder()][SessionService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://discoveryengine.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::session_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::session_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `SessionService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `SessionService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[cfg(feature = "session-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "session-service")))]
#[derive(Clone, Debug)]
pub struct SessionService {
    inner: std::sync::Arc<dyn super::stub::dynamic::SessionService>,
}

#[cfg(feature = "session-service")]
impl SessionService {
    /// Returns a builder for [SessionService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::client::SessionService;
    /// let client = SessionService::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::session_service::ClientBuilder {
        gax::client_builder::internal::new_builder(super::builder::session_service::client::Factory)
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::SessionService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::SessionService>> {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::SessionService> {
        super::transport::SessionService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::SessionService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::SessionService::new)
    }

    /// Creates a Session.
    ///
    /// If the [Session][google.cloud.discoveryengine.v1.Session] to create already
    /// exists, an ALREADY_EXISTS error is returned.
    ///
    /// [google.cloud.discoveryengine.v1.Session]: crate::model::Session
    pub fn create_session(&self) -> super::builder::session_service::CreateSession {
        super::builder::session_service::CreateSession::new(self.inner.clone())
    }

    /// Deletes a Session.
    ///
    /// If the [Session][google.cloud.discoveryengine.v1.Session] to delete does
    /// not exist, a NOT_FOUND error is returned.
    ///
    /// [google.cloud.discoveryengine.v1.Session]: crate::model::Session
    pub fn delete_session(&self) -> super::builder::session_service::DeleteSession {
        super::builder::session_service::DeleteSession::new(self.inner.clone())
    }

    /// Updates a Session.
    ///
    /// [Session][google.cloud.discoveryengine.v1.Session] action type cannot be
    /// changed. If the [Session][google.cloud.discoveryengine.v1.Session] to
    /// update does not exist, a NOT_FOUND error is returned.
    ///
    /// [google.cloud.discoveryengine.v1.Session]: crate::model::Session
    pub fn update_session(&self) -> super::builder::session_service::UpdateSession {
        super::builder::session_service::UpdateSession::new(self.inner.clone())
    }

    /// Gets a Session.
    pub fn get_session(&self) -> super::builder::session_service::GetSession {
        super::builder::session_service::GetSession::new(self.inner.clone())
    }

    /// Lists all Sessions by their parent
    /// [DataStore][google.cloud.discoveryengine.v1.DataStore].
    ///
    /// [google.cloud.discoveryengine.v1.DataStore]: crate::model::DataStore
    pub fn list_sessions(&self) -> super::builder::session_service::ListSessions {
        super::builder::session_service::ListSessions::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::session_service::ListOperations {
        super::builder::session_service::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::session_service::GetOperation {
        super::builder::session_service::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn cancel_operation(&self) -> super::builder::session_service::CancelOperation {
        super::builder::session_service::CancelOperation::new(self.inner.clone())
    }
}

/// Implements a client for the Discovery Engine API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_discoveryengine_v1::client::SiteSearchEngineService;
/// let client = SiteSearchEngineService::builder().build().await?;
/// // use `client` to make requests to the Discovery Engine API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Service for managing site search related resources.
///
/// # Configuration
///
/// To configure `SiteSearchEngineService` use the `with_*` methods in the type returned
/// by [builder()][SiteSearchEngineService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://discoveryengine.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::site_search_engine_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::site_search_engine_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `SiteSearchEngineService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `SiteSearchEngineService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[cfg(feature = "site-search-engine-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "site-search-engine-service")))]
#[derive(Clone, Debug)]
pub struct SiteSearchEngineService {
    inner: std::sync::Arc<dyn super::stub::dynamic::SiteSearchEngineService>,
}

#[cfg(feature = "site-search-engine-service")]
impl SiteSearchEngineService {
    /// Returns a builder for [SiteSearchEngineService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::client::SiteSearchEngineService;
    /// let client = SiteSearchEngineService::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::site_search_engine_service::ClientBuilder {
        gax::client_builder::internal::new_builder(
            super::builder::site_search_engine_service::client::Factory,
        )
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::SiteSearchEngineService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<
        std::sync::Arc<dyn super::stub::dynamic::SiteSearchEngineService>,
    > {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::SiteSearchEngineService> {
        super::transport::SiteSearchEngineService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::SiteSearchEngineService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::SiteSearchEngineService::new)
    }

    /// Gets the
    /// [SiteSearchEngine][google.cloud.discoveryengine.v1.SiteSearchEngine].
    ///
    /// [google.cloud.discoveryengine.v1.SiteSearchEngine]: crate::model::SiteSearchEngine
    pub fn get_site_search_engine(
        &self,
    ) -> super::builder::site_search_engine_service::GetSiteSearchEngine {
        super::builder::site_search_engine_service::GetSiteSearchEngine::new(self.inner.clone())
    }

    /// Creates a [TargetSite][google.cloud.discoveryengine.v1.TargetSite].
    ///
    /// [google.cloud.discoveryengine.v1.TargetSite]: crate::model::TargetSite
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_target_site(
        &self,
    ) -> super::builder::site_search_engine_service::CreateTargetSite {
        super::builder::site_search_engine_service::CreateTargetSite::new(self.inner.clone())
    }

    /// Creates [TargetSite][google.cloud.discoveryengine.v1.TargetSite] in a
    /// batch.
    ///
    /// [google.cloud.discoveryengine.v1.TargetSite]: crate::model::TargetSite
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn batch_create_target_sites(
        &self,
    ) -> super::builder::site_search_engine_service::BatchCreateTargetSites {
        super::builder::site_search_engine_service::BatchCreateTargetSites::new(self.inner.clone())
    }

    /// Gets a [TargetSite][google.cloud.discoveryengine.v1.TargetSite].
    ///
    /// [google.cloud.discoveryengine.v1.TargetSite]: crate::model::TargetSite
    pub fn get_target_site(&self) -> super::builder::site_search_engine_service::GetTargetSite {
        super::builder::site_search_engine_service::GetTargetSite::new(self.inner.clone())
    }

    /// Updates a [TargetSite][google.cloud.discoveryengine.v1.TargetSite].
    ///
    /// [google.cloud.discoveryengine.v1.TargetSite]: crate::model::TargetSite
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn update_target_site(
        &self,
    ) -> super::builder::site_search_engine_service::UpdateTargetSite {
        super::builder::site_search_engine_service::UpdateTargetSite::new(self.inner.clone())
    }

    /// Deletes a [TargetSite][google.cloud.discoveryengine.v1.TargetSite].
    ///
    /// [google.cloud.discoveryengine.v1.TargetSite]: crate::model::TargetSite
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_target_site(
        &self,
    ) -> super::builder::site_search_engine_service::DeleteTargetSite {
        super::builder::site_search_engine_service::DeleteTargetSite::new(self.inner.clone())
    }

    /// Gets a list of [TargetSite][google.cloud.discoveryengine.v1.TargetSite]s.
    ///
    /// [google.cloud.discoveryengine.v1.TargetSite]: crate::model::TargetSite
    pub fn list_target_sites(&self) -> super::builder::site_search_engine_service::ListTargetSites {
        super::builder::site_search_engine_service::ListTargetSites::new(self.inner.clone())
    }

    /// Creates a [Sitemap][google.cloud.discoveryengine.v1.Sitemap].
    ///
    /// [google.cloud.discoveryengine.v1.Sitemap]: crate::model::Sitemap
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_sitemap(&self) -> super::builder::site_search_engine_service::CreateSitemap {
        super::builder::site_search_engine_service::CreateSitemap::new(self.inner.clone())
    }

    /// Deletes a [Sitemap][google.cloud.discoveryengine.v1.Sitemap].
    ///
    /// [google.cloud.discoveryengine.v1.Sitemap]: crate::model::Sitemap
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_sitemap(&self) -> super::builder::site_search_engine_service::DeleteSitemap {
        super::builder::site_search_engine_service::DeleteSitemap::new(self.inner.clone())
    }

    /// Fetch [Sitemap][google.cloud.discoveryengine.v1.Sitemap]s in a
    /// [DataStore][google.cloud.discoveryengine.v1.DataStore].
    ///
    /// [google.cloud.discoveryengine.v1.DataStore]: crate::model::DataStore
    /// [google.cloud.discoveryengine.v1.Sitemap]: crate::model::Sitemap
    pub fn fetch_sitemaps(&self) -> super::builder::site_search_engine_service::FetchSitemaps {
        super::builder::site_search_engine_service::FetchSitemaps::new(self.inner.clone())
    }

    /// Upgrade from basic site search to advanced site search.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn enable_advanced_site_search(
        &self,
    ) -> super::builder::site_search_engine_service::EnableAdvancedSiteSearch {
        super::builder::site_search_engine_service::EnableAdvancedSiteSearch::new(
            self.inner.clone(),
        )
    }

    /// Downgrade from advanced site search to basic site search.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn disable_advanced_site_search(
        &self,
    ) -> super::builder::site_search_engine_service::DisableAdvancedSiteSearch {
        super::builder::site_search_engine_service::DisableAdvancedSiteSearch::new(
            self.inner.clone(),
        )
    }

    /// Request on-demand recrawl for a list of URIs.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn recrawl_uris(&self) -> super::builder::site_search_engine_service::RecrawlUris {
        super::builder::site_search_engine_service::RecrawlUris::new(self.inner.clone())
    }

    /// Verify target sites' ownership and validity.
    /// This API sends all the target sites under site search engine for
    /// verification.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn batch_verify_target_sites(
        &self,
    ) -> super::builder::site_search_engine_service::BatchVerifyTargetSites {
        super::builder::site_search_engine_service::BatchVerifyTargetSites::new(self.inner.clone())
    }

    /// Returns list of target sites with its domain verification status.
    /// This method can only be called under data store with BASIC_SITE_SEARCH
    /// state at the moment.
    pub fn fetch_domain_verification_status(
        &self,
    ) -> super::builder::site_search_engine_service::FetchDomainVerificationStatus {
        super::builder::site_search_engine_service::FetchDomainVerificationStatus::new(
            self.inner.clone(),
        )
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::site_search_engine_service::ListOperations {
        super::builder::site_search_engine_service::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::site_search_engine_service::GetOperation {
        super::builder::site_search_engine_service::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn cancel_operation(&self) -> super::builder::site_search_engine_service::CancelOperation {
        super::builder::site_search_engine_service::CancelOperation::new(self.inner.clone())
    }
}

/// Implements a client for the Discovery Engine API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_discoveryengine_v1::client::UserEventService;
/// let client = UserEventService::builder().build().await?;
/// // use `client` to make requests to the Discovery Engine API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Service for ingesting end user actions on a website to Discovery Engine API.
///
/// # Configuration
///
/// To configure `UserEventService` use the `with_*` methods in the type returned
/// by [builder()][UserEventService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://discoveryengine.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::user_event_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::user_event_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `UserEventService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `UserEventService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[cfg(feature = "user-event-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "user-event-service")))]
#[derive(Clone, Debug)]
pub struct UserEventService {
    inner: std::sync::Arc<dyn super::stub::dynamic::UserEventService>,
}

#[cfg(feature = "user-event-service")]
impl UserEventService {
    /// Returns a builder for [UserEventService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::client::UserEventService;
    /// let client = UserEventService::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::user_event_service::ClientBuilder {
        gax::client_builder::internal::new_builder(
            super::builder::user_event_service::client::Factory,
        )
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::UserEventService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::UserEventService>>
    {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::UserEventService> {
        super::transport::UserEventService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::UserEventService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::UserEventService::new)
    }

    /// Writes a single user event.
    pub fn write_user_event(&self) -> super::builder::user_event_service::WriteUserEvent {
        super::builder::user_event_service::WriteUserEvent::new(self.inner.clone())
    }

    /// Writes a single user event from the browser. This uses a GET request to
    /// due to browser restriction of POST-ing to a third-party domain.
    ///
    /// This method is used only by the Discovery Engine API JavaScript pixel and
    /// Google Tag Manager. Users should not call this method directly.
    pub fn collect_user_event(&self) -> super::builder::user_event_service::CollectUserEvent {
        super::builder::user_event_service::CollectUserEvent::new(self.inner.clone())
    }

    /// Deletes permanently all user events specified by the filter provided.
    /// Depending on the number of events specified by the filter, this operation
    /// could take hours or days to complete. To test a filter, use the list
    /// command first.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn purge_user_events(&self) -> super::builder::user_event_service::PurgeUserEvents {
        super::builder::user_event_service::PurgeUserEvents::new(self.inner.clone())
    }

    /// Bulk import of user events. Request processing might be
    /// synchronous. Events that already exist are skipped.
    /// Use this method for backfilling historical user events.
    ///
    /// Operation.response is of type ImportResponse. Note that it is
    /// possible for a subset of the items to be successfully inserted.
    /// Operation.metadata is of type ImportMetadata.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn import_user_events(&self) -> super::builder::user_event_service::ImportUserEvents {
        super::builder::user_event_service::ImportUserEvents::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::user_event_service::ListOperations {
        super::builder::user_event_service::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::user_event_service::GetOperation {
        super::builder::user_event_service::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn cancel_operation(&self) -> super::builder::user_event_service::CancelOperation {
        super::builder::user_event_service::CancelOperation::new(self.inner.clone())
    }
}

/// Implements a client for the Discovery Engine API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_discoveryengine_v1::client::UserLicenseService;
/// let client = UserLicenseService::builder().build().await?;
/// // use `client` to make requests to the Discovery Engine API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Service for managing User Licenses.
///
/// # Configuration
///
/// To configure `UserLicenseService` use the `with_*` methods in the type returned
/// by [builder()][UserLicenseService::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://discoveryengine.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::user_license_service::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::user_license_service::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `UserLicenseService` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `UserLicenseService` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[cfg(feature = "user-license-service")]
#[cfg_attr(docsrs, doc(cfg(feature = "user-license-service")))]
#[derive(Clone, Debug)]
pub struct UserLicenseService {
    inner: std::sync::Arc<dyn super::stub::dynamic::UserLicenseService>,
}

#[cfg(feature = "user-license-service")]
impl UserLicenseService {
    /// Returns a builder for [UserLicenseService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_discoveryengine_v1::client::UserLicenseService;
    /// let client = UserLicenseService::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::user_license_service::ClientBuilder {
        gax::client_builder::internal::new_builder(
            super::builder::user_license_service::client::Factory,
        )
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::UserLicenseService + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::UserLicenseService>>
    {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::UserLicenseService> {
        super::transport::UserLicenseService::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::UserLicenseService> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::UserLicenseService::new)
    }

    /// Lists the User Licenses.
    pub fn list_user_licenses(&self) -> super::builder::user_license_service::ListUserLicenses {
        super::builder::user_license_service::ListUserLicenses::new(self.inner.clone())
    }

    /// Updates the User License.
    /// This method is used for batch assign/unassign licenses to users.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn batch_update_user_licenses(
        &self,
    ) -> super::builder::user_license_service::BatchUpdateUserLicenses {
        super::builder::user_license_service::BatchUpdateUserLicenses::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::user_license_service::ListOperations {
        super::builder::user_license_service::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::user_license_service::GetOperation {
        super::builder::user_license_service::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn cancel_operation(&self) -> super::builder::user_license_service::CancelOperation {
        super::builder::user_license_service::CancelOperation::new(self.inner.clone())
    }
}
